package core.semantic;

import core.KeyWord;

/**
 * It represents a semantic tuple to be manipulated on the stack,
 * it�s necessary to represent the variables of the source code.
 */
public class SemanticTuple{

	private String identifier;
	private KeyWord type;
	public enum Class {VARIABLE, METHOD_NAME, ARRAY_VARIABLE};
	private Class idClass;
	
	/**
	 * Constructs a new SemanticTuple using the data provided.
	 * @param identifier The identifier of variable represented.
	 * @param type The type of the variable represented.
	 * @param idClass The idClasse of the variable represented.
	 */
	public SemanticTuple(String identifier, KeyWord type, Class idClass) {
		super();
		this.identifier = identifier;
		this.type = type;
		this.idClass = idClass;
	}

	/**
	 * Returns the type of the variable represented by this tuple.
	 * @return The type of the variable represented by this tuple.
	 */
	public KeyWord getType() {
		return type;
	}

	/**
	 * It permites to define the type of the variable represented by this tuple.
	 * @param type The type of the variable represented by this tuple.
	 */
	public void setType(KeyWord type) {
		this.type = type;
	}

	/**
	 * Returns the idClass of the variable represented by this tuple.
	 * @return The idClass of the variable represented by this tuple.
	 */
	public Class getIdClass() {
		return idClass;
	}

	/**
	 * It permites to define the idClass of the variable represented by this tuple.
	 * @param idClass The idClass of the variable represented by this tuple.
	 */
	public void setIdClass(Class idClass) {
		this.idClass = idClass;
	}
	
	/**
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	public boolean equals(Object obj) {
		if (obj instanceof SymbolTable) {
			SemanticTuple o = (SemanticTuple) obj;
			return identifier.equals(o.identifier) 
			&& idClass.equals(o.idClass);
		}
		return false;
	}
	
	/**
	 * Returns the identifier of the variable represented by this tuple.
	 * @return The identifier of the variable represented by this tuple.
	 */
	public String getIdentifier() {
		return identifier;
	}

	/**
	 * It permites to define the identifier of the variable represented by this tuple.
	 * @param identifier The identifier of the variable represented by this tuple.
	 */
	public void setIdentifier(String identifier) {
		this.identifier = identifier;
	}
}
